<!DOCTYPE html>
<html>
<head>
<title>Linux下 PHP开发常用软件安装配置</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="/js/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="/js/index.js"></script>
<script type="text/javascript" src="/js/highlighter/scripts/shCore.js"></script>
<script type="text/javascript" src="/js/highlighter/scripts/shBrushBash.js"></script>
<script type="text/javascript">
SyntaxHighlighter.config.clipboardSwf = '/js/highlighter/scripts/clipboard.swf';
SyntaxHighlighter.all();
</script>
<link href="/css/style.css" type="text/css" rel="stylesheet" />
<link type="text/css" rel="stylesheet" href="/js/highlighter/styles/shCore.css"/>
<link type="text/css" rel="stylesheet" href="/js/highlighter/styles/shThemeEclipse.css"/>
</head>
<body>
<div id="slideContainer">
    <ul class="hySlideContent">
        <li class="slideItem">
            <h3 class="pt10">安装Tengine</h3>
            <pre class="brush: bash;">
                    #首先安装wget，wget是一个命令行下载工具
                    #这里是yum命令是redhat系列linux系统（如centos）的包管理工具；
                    #debian系列（如ubuntu）的包管理工具是apt-get
                    yum install wget
                    #进入到github, 搜索tengin
                    #找到 alibaba/tengine 这个项目
                    wget https://github.com/alibaba/tengine/archive/master.zip
                    yum install unzip
                    mv master.zip tengine-master.zip
                    unzip tengine-master.zip
                    cd tengine-master
                    ./configure
                    make
                    make install
            </pre>
        </li>
        <li class="slideItem">
            <h3 class="pt10">启动 Tengine 访问欢迎页面，安装成功!</h3>
           <pre class="brush: bash;">
                    #启动tengine
                    /usr/local/nginx/sbin/nginx
                    #这时候要是在浏览器输入ip能够访问到如下页面说明Tengine安装成功了
                    #如果不能访问很可能是端口未打开，用如下命令打开端口重试
                    iptables -I INPUT -ptcp --dport  80 -j ACCEPT
                    service iptables save
                    service iptables restart
            </pre>
            <div class="imageContainer">
                <p class="pt10"><img width="680" src="./images/tengin_welcome_page.png" /></p>
            </div>
        </li>
        <li class="slideItem">
            <h3 class="pt10">PHP安装</h3>
            <pre class="brush: bash;">
                    wget http://cn2.php.net/distributions/php-5.6.6.tar.gz
                    tar -zxvf php-5.6.3.tar.gz
                    cd php-5.6.3
                    ./configure --enable-fpm --with-mysql --with-mysqli --with-mcrypt --with-pcre-regex
                    #说明：configure这个脚本有很多参数，可以用 ./configure -h 来查看它的用法
                    #常见问题1：configure: error: xml2-config not found. Please check your libxml2 installation
                    #解决办法：
                    yum install libxml2
                    yum install libxml2-devel
                    #常见问题2：configure: error: mcrypt.h not found. Please reinstall libmcrypt.
                    #解决办法：yum install libmcrypt
                    #常见问题3：No package libmcrypt available
                    #这个时候centos源里面没有自带这个库，需要手动去下载然后编译安装
                    cd ..
                    wget http://softlayer.dl.sourceforge.net/sourceforge/mcrypt/libmcrypt-2.5.8.tar.gz
                    tar -zxvf libmcrypt-2.5.8.tar.gz
                    cd libmcrypt-2.5.8
                    ./configure
                    make
                    make install

                    cd ../php-5.6.3
                    ./configure --enable-fpm --with-mysql --with-mysqli --with-mcrypt --with-pcre-regex
                    make all install
            </pre>
        </li>
        <li class="slideItem">
            <h3 class="pt10">配置PHP和Tengine</h3>
            <pre class="brush: bash;">
                    mkdir /usr/local/nginx/conf/vhosts
                    vim /usr/local/nginx/conf/nginx.conf
                    tabnew /usr/local/nginx/conf/vhosts/welcome.conf
                    cp /vagrant/php-5.6.3/php.ini-development /usr/local/lib/php.ini
            </pre>
            <div class="imageContainer">
                <p><img width="670" src="./images/tengin_config01.png" /></p>
            </div>
        </li>
        <li class="slideItem">
            <h3 class="pt10">PHP_Redis扩展安装</h3>
            <pre class="brush: bash;">
                    wget https://github.com/owlient/phpredis/archive/master.zip
                    mv master.zip php_redis.zip
                    unzip php_redis.zip

                    cd phpredis-master
                    phpize
                    ./configure --with-php-config=/usr/local/bin/php-config
                    make
                    make install

                    #修改php.ini文件
                    vim /usr/local/lib/php.ini
                    #加入extension=redis.so 然后重启php-fpm

                    #提示：安装php自带扩展也可用这个方法 进入php源码对应扩展的目录 使用以上操作即可
            </pre>
        </li>
        <li class="slideItem">
            <h3 class="pt10">PHP_Redis扩展安装成功</h3>
            <div class="imageContainer">
                <p class="pt10"><img width="680" src="./images/phpredis_ext_success.png" /></p>
                <p class="pt10"><img width="680" src="./images/redis_ext.png" /></p>
            </div>
        </li>
        <li class="slideItem">
            <h3 class="pt10">MySQL安装</h3>
            <pre class="brush: bash;">
                    yum install mysql-server
                    service mysqld start
            </pre>
            <div class="imageContainer">
                <p><img width="680" src="./images/mysql_install_success.png" /></p>
            </div>
        </li>
        <li class="slideItem">
            <h3 class="pt10">php-fpm启动脚本</h3>
            <pre class="brush: bash;">
                    #php安装完成以后每次修改php配置以后都得，重启php-fpm
                    #通常情况下命令如下
                    killall php-fpm
                    php-fpm
                    #居然要输两条命令，很是不方便，要是有个php-fpm的启动结束脚本就好了
                    #幸运的是php源码包里面包含了这个脚本，把他copy到/etc/init.d/目录下
                    cp /vagrant/php-5.6.3/sapi/fpm/init.d.php-fpm.in /etc/init.d/php-fpm
                    chkconfig --add php-fpm
                    chkconfig --level 2345 php-fpm on
                </code>
            </pre>
        </li>
    </ul>
</div>
</body>
</html>
